home *** CD-ROM | disk | FTP | other *** search
/ A is for ART, C is for Cezanne / A is for ART, C is for Cezanne.iso / mac / SETUP.RUL < prev    next >
Text File  |  1996-05-22  |  9KB  |  284 lines

  1. /*----------------------------------------------------------------------------*\
  2.  *
  3.  *    File Name:  SETUP.RUL
  4.  *
  5.  *  Description:  Cezanne Windows 3.1/Windows 95 Installation
  6.  *
  7.  *       Author:  Randall Isaac, C-Wave.       Date: 5-9-96
  8.  *
  9.  *     Comments:  This script performs a basic installation from a CD to
  10.  *                a Windows 95 or Windows 3.1 platform.
  11.  *
  12. \*----------------------------------------------------------------------------*/
  13.  
  14. declare
  15.  
  16. // Constant declarations.
  17. #define SPACE_REQUIRED          3500000          // Disk space in bytes.
  18. #define APP_NAME                "CEZANNE"
  19. #define PROGRAM_FOLDER_NAME     "A is for Art"
  20. #define APPBASE_PATH            "Cezanne\\"
  21. #define COMPANY_NAME            "C-Wave"
  22. #define PRODUCT_NAME            "Cezanne"
  23. #define PRODUCT_VERSION         "1.0"
  24. #define DEINSTALL_KEY           "CezanneDeinstKey"
  25. #define UNINSTALL_NAME          "Cezanne"
  26. #define PRODUCT_KEY             "Cezanne.exe"
  27. #define EXE_NAME                "Cezanne.exe"
  28. #define MEDIA_DIR               "Data\\"
  29. #define MEDIA_SRC               "Data\\"
  30. #define PROGRAM_SRC             "Cezanne\\"
  31. #define INI_FILE                "Lingo.INI"
  32. #define README_FILE             "Readme.txt"
  33.  
  34.     // Global variable declarations.
  35.     STRING  svFolder, svDir, szMsg, szFileSet, szMediaPath, szTitle, svUninstLogFile;
  36.     STRING  svTarget, szProgram, szReadme, szTemp, szAppPath, szInstallPath;
  37.     BOOL    bSpaceOk, bWinNT, bWin32s, bWin31, bIsShellExplorer;
  38.     NUMBER  nResult, nvINI, nDLLResult;
  39.  
  40.     // Internal Function declarations.
  41.     prototype SetupScreen();
  42.     prototype CheckRequirements();
  43.  
  44.  
  45. program
  46.  
  47. StartHere:
  48.         Disable( BACKGROUND );
  49.  
  50.         // Set installation info., which is required for registry entries.
  51.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  52.  
  53.         // Set up thr installation screen.
  54.         SetupScreen();
  55.         Enable( DIALOGCACHE );
  56.  
  57.  
  58.    // Create a Welcome dialog.
  59.    WelcomeDlg:
  60.         Disable( BACKBUTTON );
  61.         Welcome( "", 0 );
  62.         Enable( BACKBUTTON );
  63.  
  64.         // Test target system for proper configuration.
  65.         CheckRequirements();
  66.  
  67.  
  68.    // Ask user for a destination location for the installation.--
  69.    GetTargetDirectory:
  70.         svTarget = TARGETDISK ^ APPBASE_PATH;
  71.         if ( AskDestPath( "", szMsg,
  72.                           svTarget, 0 ) = 12 ) then
  73.            goto WelcomeDlg;
  74.         endif;
  75.  
  76.         // Perform space check of target drive.
  77.         bSpaceOk = TRUE;
  78.         if (GetDiskSpace( svTarget ) < SPACE_REQUIRED) then
  79.            szMsg = "There is not enough space available on the disk\n" +
  80.                    "'" + svTarget + "' \n" +
  81.                    "Please free up some space or change the target location\n" +
  82.                    "to a different disk";
  83.            MessageBox( szMsg, WARNING );
  84.            bSpaceOk = FALSE;
  85.         endif;
  86.  
  87.          // If not enough space, ask user to try again.
  88.         if (bSpaceOk = FALSE) goto GetTargetDirectory;
  89.  
  90.         // Set the App Paths key for the main program.
  91.         szAppPath = svTarget ^ "PROGRAM";
  92.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  93.         szProgram = svTarget ^ EXE_NAME;
  94.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  95.  
  96.         TARGETDIR = svTarget ^ "\\";    //ensure trailing '\'
  97.  
  98.    CreateMediaSubDir:
  99.         //Now define the media subdirectory
  100.         szTemp= TARGETDIR ^ MEDIA_DIR;    //create subdir path
  101.          if ( ExistsDir( szTemp ) = NOTEXISTS ) then
  102.              CreateDir( szTemp );
  103.          endif;
  104.  
  105.  
  106.    TransferFiles:
  107.         // Prepare InstallShield to record deinstallation information.
  108.         DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  109.         RegDBSetItem( REGDB_UNINSTALL_NAME, UNINSTALL_NAME );
  110.  
  111.         // Set up progress indicator and information gauge.
  112.         Disable( DIALOGCACHE );
  113.         Enable( STATUSDLG );
  114.  
  115.         // Perform the file set.
  116.         SetStatusWindow( 5, "Copying program files..." );
  117.          VarSave(SRCTARGETDIR);
  118.           StatusUpdate( ON, 20 );
  119.           if ( bWin31 ) then
  120.               CopyFile( "Uninst16.exe", "UnInst16.exe" );
  121.           else
  122.               CopyFile( "Uninst.exe", "UnInst.exe" );
  123.           endif;
  124.           StatusUpdate( ON, 25 );
  125.           CopyFile( README_FILE, README_FILE );
  126.           SRCDIR = SRCDIR ^ PROGRAM_SRC;
  127.           StatusUpdate( ON, 70 );
  128.  
  129.           if ( bWin31 ) then
  130.              CopyFile( "CezWin31.exe", EXE_NAME );
  131.           else
  132.              CopyFile( "CezWin95.exe", EXE_NAME );
  133.           endif;
  134.           CopyFile( INI_FILE, INI_FILE );   //move INI so it will be registered
  135.                                             // for uninstall.
  136.           TARGETDIR = TARGETDIR ^ MEDIA_DIR;
  137.           SRCDIR = SRCDIR ^ MEDIA_SRC;
  138.           StatusUpdate( ON, 90 );
  139.           XCopyFile( "*.*", "*.*", INCLUDE_SUBDIR );
  140.           VarRestore(SRCTARGETDIR);
  141.  
  142.         Delay( 1 );
  143.         Disable( STATUSDLG );
  144.  
  145.    //Add a line to the INI file with source CD drive
  146.    CreateINI:
  147.     szTemp = "CDROM=" + SRCDIR;
  148.         OpenFileMode( FILE_MODE_APPEND );
  149.         OpenFile( nvINI, TARGETDIR, INI_FILE );
  150.         WriteLine( nvINI, szTemp );
  151.         CloseFile( nvINI );
  152.  
  153.  
  154.    // Create program folders and icons.
  155.    InstallProgramItems:
  156.         SetStatusWindow( 90, "Creating Program Folder and Icons...." );
  157.  
  158.         // create program group
  159.         if ( CreateProgramFolder( PROGRAM_FOLDER_NAME ) < 0 ) then
  160.             MessageBox( "Failed to create program folder.", SEVERE );
  161.             exit;
  162.         endif;
  163.  
  164.         // create program icon
  165.         szProgram = TARGETDIR ^ EXE_NAME;
  166.         szReadme  = TARGETDIR ^ README_FILE;
  167.         LongPathToQuote( szProgram, TRUE );
  168.         AddFolderIcon( PROGRAM_FOLDER_NAME, APP_NAME, szProgram,
  169.                           TARGETDIR, "", 0, "", REPLACE );
  170.         AddFolderIcon( PROGRAM_FOLDER_NAME, "Read Me", szReadme,
  171.                           TARGETDIR, "", 0, "", REPLACE );
  172.         Delay( 1 );
  173.  
  174.  
  175.    // Announce setup complete and offer to read README file.e
  176.    FinalInstallProcess:
  177.         SetStatusWindow( 100, "Installation complete." );
  178.  
  179.         if (AskYesNo( "Do you want to view the README file now?", YES ) = YES) then
  180.            LaunchAppAndWait( "NOTEPAD.EXE", svTarget ^ "README.TXT", WAIT );
  181.            Delay( 1 );
  182.         endif;
  183.  
  184.         szMsg = "Setup is complete.  You may run the installed program "+
  185.                 "by double-clicking on the program icon.";
  186.         MessageBox( szMsg, INFORMATION );
  187.  
  188.         exit;
  189.  
  190.  
  191. /*---------------------------------------------------------------------------*\
  192.  *
  193.  * Function:  SetupScreen
  194.  *
  195.  *  Purpose:  This function will set up the screen look.  This includes
  196.  *            colors, fonts, text to be displayed, etc.
  197.  *
  198.  *
  199.  * Comments:
  200. \*---------------------------------------------------------------------------*/
  201.  
  202. function SetupScreen()
  203.         number nDx, nDy;
  204. begin
  205.         GetExtents( nDx, nDy );
  206.  
  207.         Enable( FULLWINDOWMODE );
  208.         Enable( INDVFILESTATUS );
  209.         Enable( BITMAP256COLORS );
  210.  
  211.         SetTitle( "Installing " + APP_NAME, 24, WHITE );
  212.  
  213.         SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
  214.         SetColor( STATUSBAR, BLUE );     // Bright blue.
  215.         SetTitle( "Cezanne Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
  216.  
  217.         Enable( BACKGROUND );
  218.  
  219.         //Place custom bitmap and install windows
  220.         szInstallPath = SRCDIR ^ "INSTALL.BMP";
  221.         PlaceBitmap( szInstallPath, 0, 15, 15, UPPER_RIGHT );
  222.         SetInfoWindow( "Information", "Info1.txt" );
  223.  
  224.         Delay( 1 );
  225.  
  226. end;
  227.  
  228.  
  229. /*---------------------------------------------------------------------------*\
  230.  *
  231.  * Function:  CheckRequirements
  232.  *
  233.  *  Purpose:  This function will check all minimum requirements for the
  234.  *            application being installed.  If any fail, then the user
  235.  *            is informed and the installation is terminated.
  236.  *
  237.  *
  238.  * Comments:
  239. \*---------------------------------------------------------------------------*/
  240.  
  241. function CheckRequirements()
  242. number nvDx, nvDy;
  243. number nvResult;
  244. STRING svResult;
  245.  
  246. begin
  247.  
  248.         // Check screen resolution.
  249.         GetExtents( nvDx, nvDy );
  250.         if (nvDy < 480) then
  251.            MessageBox( "This program requires VGA or better resolution.", WARNING );
  252.            exit;
  253.         endif;
  254.  
  255.         // Determine the target system's operating system.
  256.         GetSystemInfo( OS, nvResult, svResult );
  257.         bWinNT  = FALSE;
  258.         bWin32s = FALSE;
  259.         bWin31  = FALSE;
  260.         bIsShellExplorer = FALSE;
  261.  
  262.         if ( nvResult = IS_WINDOWS ) then
  263.             bWin31 = TRUE;          // this is a Win31 system
  264.         endif;
  265.  
  266.         if (nvResult =  IS_WINDOWSNT) then
  267.            bWinNT = TRUE; // Running Windows NT.
  268.  
  269.            // Check to see if NT is using EXPLORER Shell
  270.            if( QueryShellMgr( svResult ) = 0 ) then
  271.                if( StrCompare( svResult, "EXPLORER.EXE" ) = 0 ) then
  272.                    bIsShellExplorer = TRUE;
  273.                endif;
  274.            endif;
  275.  
  276.         elseif (nvResult =  IS_WIN32S) then
  277.            bWin32s = TRUE; // Running Win32s.
  278.         endif;
  279.  
  280. end;
  281.  
  282.  
  283.  
  284.